Fix crash of certain D108 Garmins when writing routes.
authorrobertl <robertl>
Sun, 13 Aug 2006 21:40:35 +0000 (21:40 +0000)
committerrobertl <robertl>
Sun, 13 Aug 2006 21:40:35 +0000 (21:40 +0000)
garmin.c
jeeps/gpsapp.c

index 054c9c28ee0c3dee324aa4056fb92ff894ba7327..4698f7d7fc6f3769304f740d626d3b1be1ce80a5 100644 (file)
--- a/garmin.c
+++ b/garmin.c
@@ -705,6 +705,12 @@ route_waypt_pr(const waypoint *wpt)
        if (wpt->altitude != unknown_alt) {
                rte->alt = wpt->altitude;
        }
+       if (wpt->altitude != unknown_alt) {
+               rte->alt = wpt->altitude;
+       } else {
+               rte->alt_is_unknown = 1;
+               rte->alt = 0;
+       }
        strncpy(rte->ident, wpt->shortname, sizeof(rte->ident));
        rte->ident[sizeof(rte->ident)-1] = 0;
 
index 204d198b9511127cb4690cf89393d87ab8594ae6..104f535c798fe7870c7d90bb37097819cd25901f 100644 (file)
@@ -2063,7 +2063,11 @@ static void GPS_D108_Send(UC *data, GPS_PWay way, int32 *len)
     GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lon));
     p+=sizeof(int32);
 
-    GPS_Util_Put_Float(p,way->alt);
+    if (way->alt_is_unknown) {
+       GPS_Util_Put_Float(p,(const float) 1.0e25);
+    } else {
+       GPS_Util_Put_Float(p,way->alt);
+    }
     p+=sizeof(float);
     GPS_Util_Put_Float(p,way->dpth);
     p+=sizeof(float);